NCN26010 Example Software: NCN26010 Example Software

NCN26010 Example Software 1.0.0
Example Code to get started with the NCN26010 T1S device.
  • Main Page
  • Data Structures
  • Files
NCN26010 Example Software

The NCN26010 device is an Ethernet Transceiver designed for industrial multi-drop Ethernet. It provides all physical layer functions needed to transmit and receive data over a single unshielded twisted pair. The example software provided by onsemi is designed to provide the necessary firmware and application examples to help designers quickly integrate the NCN26010 into their systems.

Software Architecture

The provided software follows a modular design to allow the software to be quickly adapted to be used with any microcontroller or to be used with various implementations of the TCP and IP layers of the network stack. As illustrated below, the standard network stack consists of five layers: Physical (PHY), Data Link (MAC), Network (IP), Transport (TCP), and Application. The NCN26010 provides a hardware implementation of the MAC and PHY layers of the network stack. There are many existing open source or proprietary implantations of the TCP and IP layers that a designer may choose from. The software provided with the NCN26010 is designed to provide the connection between the IP and MAC layers of the stack.

The provided software includes three required modules and one optional module. The required modules include a module to handle interaction with the TCP/IP Implementation, a module to handle hardware specific details, and the core driver module that configures the NCN26010 and handles errors. The optional module handles interactions with the operating system to yield the CPU to other tasks when not processing messages. If no OS module is provided the system defaults to call functions in the hardware specific module to sleep the CPU until the NCN26010 signals data is available with an interrupt. The interfaces for these modules are described in T1S_TCP-IP.h, T1S_Hardware.h, NCN26010.h and T1S_OS.h, respectively.

The core driver module remains unchanged for any combination of hardware and TCP/IP implementations. The hardware specific module and the TCP/IP modules are intended to be implemented by the system designer to match their system. We provide the following example implementations to support systems with the following hardware and TCP/IP implementations:

 | Raspberry Pi | STM32 | RSL10
Linux TAP | Yes | No | No
LwIP | No | Yes | Yes
FreeRTOS | No | Yes | Yes

If other microcontrollers or TCP/IP implementations are required for the system, only the functions defined in T1S_Hardware.h or T1S_TCP-IP.h need to be implemented.

Installing the software

Raspberry Pi

If you are using the NCN26010XMNEVK getting the system up and running is simple.

  1. Install the latest version of Raspberry Pi OS onto a SD card as described at https://www.raspberrypi.com/software/
  2. Download and extract the Raspberry Pi NCN26010 software package on the raspberry pi. This can be accomplished with the following command:
    curl -o NCN26010Firmware.zip “REPLACE_URL_TO_ZIP_FILE_HERE” && \
    unzip NCN26010Firmware.zip && \
    rm RaspberryPiFirmware.zip
  3. Install the required dependencies:
    sudo apt install pigpio
  4. Enter the new directory and execute the makefile:
    cd NCN26010_RaspberryPi && make
  5. Execute the compiled program (root access is required to access SPI peripherals)
    sudo ./NCN26010_Driver
  6. Setup the a TAP connection for the user space driver to handle IP traffic.
    ./netconfig
  7. Test by pinging on the 192.1.1.x network. (By default our IP address is 192.1.1.2)
    ping 192.1.1.1

STM32

Install STM32CubeIDE

Follow the instructions provided by ST Micro here: https://www.st.com/resource/en/user_manual/um2563-stm32cubeide-installation-guide-stmicroelectronics.pdf Open the Configured Example

  1. Under file, select “Open Projects from File System…”
  2. Select Directory and navigate to the folder called onsemi_T1S
  3. Leave the default values and select finish.

Install the onsemi_T1S Software Pack

  1. Double click onsemi_T1S.ioc, once the GUI loads select “Software Packs,” then Manage Software Packs
  2. Select “From Local…” then navigate to onsemi.onsemi_T1S.1.0.0.pack, and open it.
  3. Read and Accept the License Agreement then close the manage dialog.
  4. Then select “Software Packs” again but this time click “Select Components.” Navigate to onsemi.onsemi_T1S, Network onsemi_T1S, then select either FreeRTOS or LwIP depending on which TCP/IP implementation you would like to use.
  5. Enable the onsemi_T1S software pack by selecting “Software Packs,” “onsemi_T1S,” then check the box next to “Network onsemi T1S”

Setup FreeRTOS (If you selected the LwIP TCP/IP stack, you can skip this section)

  1. Enable FreeRTOS under “Middleware” “FreeRTOS.” Then select “CMSIS_V2.”
  2. In the FreeRTOS settings under “Config parameters”, adjust the heap size. We suggest 32K bytes.
  3. Under advanced settings Enable the FreeRTOS Reentrant mode.

Flash and/or Debug the Example

  1. Save the Configuration and have the STM32CubeIDE generate code.
  2. Ensure that your STM32L4xx evaluation board is connected to your computer, then Right click the project, then select debug as, then select STM32 Cortex-M C/C++ Application
  3. Wait for the build to complete and the hex to download to the board, then click play.

RSL10

Install Toolchain for Firmware Development

  1. Register and Log in to MyON account here.
  2. Download and install “ON Semiconductor IDE”.
  3. Download and install base “RSL10 CMSIS Pack”. a. To install the CMSIS pack open CMSIS Pack Manager. Click on the icon “Open Perspective” as shown below and select “CMSIS Pack Manger”. b. Click on the icon “Import Existing Packs…” to import the CMSIS pack downloaded earlier. Select “Open” to install the pack.
  4. Download and install latest version of “ARM CMSIS Pack” as per step 3.
  5. Download and install latest version of “ARM CMSIS-FreeRTOS Pack” as per step 3.
  6. Download and install latest version of “onsemi.RSL10T1S Pack”as per step 3.
  7. Once all the packs are installed, this is what CMSIS pack perspective should look like.

Import and Compile an Example Project from CMSIS Pack

  1. Select RSL10T1S pack from CMSIS pack manager. Open the drop-down for “Examples”. Right-click on the preferred example project. Select “Copy”. This will import a copy of that example project into the workspace.
  2. Right-click on the project name in Project Explorer and select “Build Configurations” to “Release” or “Debug”. Next, select “Build Project” to compile the project.

Flash and/or Debug the Example

  1. Create Run/Debug configuration for the project. Select “Run” -> “Run Configurations…”.
  2. Double-click on “GDB SEGGER J-Link Debugging”. This will generate a default configuration. Under “Main” tab, select the Project. Provide the .elf file path at “C/C++ Application”. Depending on the build configuration it can be “Release/<project_name.elf>” or “Debug/<project_name.elf>”. Or add a variable to select automatically, “${config_name:${project_name}}/<project_name.elf>”. Select “Apply”.
  3. Under “Debugger” tab, Update “Device Name” to RSL10. Select “Apply” and “Close”.
  4. To flash the board, click green play button looking icon in “Run” mode.
  5. To debug, click green bug looking icon in “Debug” mode.
  6. Detailed instructions about using the IDE can be found in RSL10 Getting Started Guide.

Unimplemented Features

This example software is provided as a basic example to support designers to use the NCN26010 in their system. There are several optimizations and additional features that onsemi has identified as potential improvements to this software. onsemi may implement some of these features and will use feedback from customers to determine how to prioritize features.

Zero Copy Data Transfer

As currently implemented, the example implementations copy data to and from buffers when transferring from the NCN26010 over the SPI. With some pointer manipulation we could eliminate these copies which saves memory and eliminates the CPU time required to copy the data. Implementing this optimization may reduce system power requirements and may allow for a less expensive MCU to be used.

Runtime Configuration

As currently implemented, all the configuration options are selected at compile time by adjusting macro constants in the ncn26010.h header file. If the configuration needs to be changed after compile time this must be done using the remote configuration options described in ncn26010.h. An option to read a file or some piece of memory to decide how to configure the NCN26010 when initializing would simplify software deployment on multiple nodes.

Serial Communication for Command Line Interface

As currently implemented, there are empty macros defined for printing debug and other information to a console. Filling in these macros with functions that send this console information over a serial interface to a host computer would help simplify debugging. It would also allow for a command line interface to configure and communicate with the MCU.

Software Timestamping

The NCN26010 does not provide timestamps for incoming frames. Certain time sensitive messages require an accurate understanding of when the message arrived. The NCN26010 can be configured to signal on its DIO pins when it detects a start of frame delimiter. Triggering an interrupt on this signal and recording a timestamp would allow a software algorithm to pair together messages with their associated timestamp.

Generated by doxygen 1.9.4


NCN26010 Example Software: Data Structures

  • Data Structures
  • Files
  • Data Structure Index
  • Data Fields
Data Structures
Here are the data structures with brief descriptions:
[detail level 12]
C ARP_Header | Header for ARP
C stBulkDataTransfer_t |
C stControlCmdReg_t |
C stDataReceive_t |
C stDataTransfer_t |
C stEthernetFrame_t |
C stRemoteConfigurationCommand_t |
C timestampFIFO_t |
▼C uCommandHeaderFooter_t |
C stHeadFootBits |
▼C uDataHeaderFooter_t |
C stRxFooterBits |
C stTxHeadBits |
▼C uStatusReg0_t |
C stVarStatusReg0 |
C uTCPIPReceiveBuffer_t |


NCN26010 Example Software: ARP_Header Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
ARP_Header Struct Reference

Header for ARP. More...

#include <Network_interface.h>

Data Fields

uint16_t | Destination [3]
uint16_t | Source [3]
uint32_t | EtherType
uint32_t | Hardware_Type
uint32_t | Protocol_Type
uint32_t | Hardware_Size
uint32_t | Protocol_Size
uint32_t | Opcode
uint32_t | Sender_MAC_address
uint32_t | Sender_IP_address
uint32_t | Target_MAC_address
uint32_t | Target_IPaddress

Detailed Description

Header for ARP.

Field Documentation

◆ Destination

uint16_t Destination[3]

this is the special reserved MAC address indicating a broadcast frame

◆ Hardware_Size

uint32_t Hardware_Size

MAC address size

◆ Opcode

uint32_t Opcode

indicates what type of ARP packet this is. A value of 1 indicates this ARP packet is a Request, or a value of 2 would indicates this ARP packet is a Response

◆ Protocol_Size

uint32_t Protocol_Size

IP address size

◆ Sender_IP_address

uint32_t Sender_IP_address

IP address of the initiator of the ARP request

◆ Sender_MAC_address

uint32_t Sender_MAC_address

MAC address of the initiator of the ARP request

◆ Source

uint16_t Source[3]

The MAC address of our sender

The documentation for this struct was generated from the following file:
  • Network_interface.h


NCN26010 Example Software: stBulkDataTransfer_t Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
stBulkDataTransfer_t Struct Reference

Data Fields

uint16_t | totalBytesToTransfer
stDataTransfer_t | stVarEachChunkTransfer
The documentation for this struct was generated from the following file:
  • NCN26010.c


NCN26010 Example Software: stControlCmdReg_t Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
stControlCmdReg_t Struct Reference

Data Fields

uint8_t | memoryMap
uint8_t | length
uint16_t | address
uint32_t | databuffer [MAX_CONTROL_CMD_LEN]
The documentation for this struct was generated from the following file:
  • NCN26010.c


NCN26010 Example Software: stDataReceive_t Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
stDataReceive_t Struct Reference

Data Fields

uDataHeaderFooter_t | receivedFooter
uint64_t | timestamp
The documentation for this struct was generated from the following file:
  • NCN26010.c


NCN26010 Example Software: stDataTransfer_t Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
stDataTransfer_t Struct Reference

Data Fields

uint8_t | startValid
uint8_t | startWordOffset
uint8_t | endValid
uint8_t | endValidOffset
uint8_t | transmitCredits
uint8_t | receiveChunkAvailable
The documentation for this struct was generated from the following file:
  • NCN26010.c


NCN26010 Example Software: stEthernetFrame_t Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
stEthernetFrame_t Struct Reference

Data Fields

uint8_t | destMACAddr [6]
uint8_t | srcMACAddr [6]
uint16_t | ethernetType
The documentation for this struct was generated from the following file:
  • NCN26010.c


NCN26010 Example Software: stRemoteConfigurationCommand_t Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
stRemoteConfigurationCommand_t Struct Reference

Data Fields

uint8_t | type
uint8_t | MMS
uint16_t | address
uint32_t | data
The documentation for this struct was generated from the following file:
  • NCN26010.h


NCN26010 Example Software: timestampFIFO_t Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
timestampFIFO_t Struct Reference

Data Fields

uint64_t * | data
uint16_t | length
uint16_t | head
uint16_t | tail
The documentation for this struct was generated from the following file:
  • NCN26010.c


NCN26010 Example Software: uCommandHeaderFooter_t Union Reference

  • Data Structure Index
  • Data Fields
Data Structures | Data Fields
uCommandHeaderFooter_t Union Reference

Data Structures

struct stHeadFootBits

Data Fields

uint8_t | controlHeaderArray [HEADER_FOOTER_SIZE]
uint32_t | controlFrameHead
struct uCommandHeaderFooter_t::stHeadFootBits | stVarHeadFootBits
The documentation for this union was generated from the following file:
  • NCN26010.c


NCN26010 Example Software: uCommandHeaderFooter_t::stHeadFootBits Struct Reference

  • Data Structure Index
  • Data Fields
  • uCommandHeaderFooter_t
  • stHeadFootBits
Data Fields
uCommandHeaderFooter_t::stHeadFootBits Struct Reference

Data Fields

uint32_t | P: 1
uint32_t | LEN: 7
uint32_t | ADDR: 16
uint32_t | MMS: 4
uint32_t | AID: 1
uint32_t | WNR: 1
uint32_t | HDRB: 1
uint32_t | DNC: 1
The documentation for this struct was generated from the following file:
  • NCN26010.c


NCN26010 Example Software: uDataHeaderFooter_t Union Reference

  • Data Structure Index
  • Data Fields
Data Structures | Data Fields
uDataHeaderFooter_t Union Reference

Data Structures

struct | stRxFooterBits
struct | stTxHeadBits

Data Fields

uint32_t | dataFrameHeadFoot
uint8_t | dataFrameHeaderBuffer [HEADER_FOOTER_SIZE]
struct uDataHeaderFooter_t::stTxHeadBits | stVarTxHeadBits
struct uDataHeaderFooter_t::stRxFooterBits | stVarRxFooterBits
The documentation for this union was generated from the following file:
  • NCN26010.c


NCN26010 Example Software: uDataHeaderFooter_t::stRxFooterBits Struct Reference

  • Data Structure Index
  • Data Fields
  • uDataHeaderFooter_t
  • stRxFooterBits
Data Fields
uDataHeaderFooter_t::stRxFooterBits Struct Reference

Data Fields

uint32_t | P: 1
uint32_t | TXC: 5
uint32_t | RTPS: 1
uint32_t | RTSA: 1
uint32_t | EBO: 6
uint32_t | EV: 1
uint32_t | FD: 1
uint32_t | SWO: 4
uint32_t | SV: 1
uint32_t | DV: 1
uint32_t | VS: 2
uint32_t | RCA: 5
uint32_t | SYNC: 1
uint32_t | HDRB: 1
uint32_t | EXST: 1
The documentation for this struct was generated from the following file:
  • NCN26010.c


NCN26010 Example Software: uDataHeaderFooter_t::stTxHeadBits Struct Reference

  • Data Structure Index
  • Data Fields
  • uDataHeaderFooter_t
  • stTxHeadBits
Data Fields
uDataHeaderFooter_t::stTxHeadBits Struct Reference

Data Fields

uint32_t | P: 1
uint32_t | RSVD3: 5
uint32_t | TS: 2
uint32_t | EBO: 6
uint32_t | EV: 1
uint32_t | RSVD2: 1
uint32_t | SWO: 4
uint32_t | SV: 1
uint32_t | DV: 1
uint32_t | VS: 2
uint32_t | RSVD1: 5
uint32_t | NORX: 1
uint32_t | SEQ: 1
uint32_t | DNC: 1
The documentation for this struct was generated from the following file:
  • NCN26010.c


NCN26010 Example Software: uStatusReg0_t Union Reference

  • Data Structure Index
  • Data Fields
Data Structures | Data Fields
uStatusReg0_t Union Reference

Data Structures

struct stVarStatusReg0

Data Fields

uint32_t | statusRegister0
struct uStatusReg0_t::stVarStatusReg0 | stVarStatusReg0
The documentation for this union was generated from the following file:
  • NCN26010.c


NCN26010 Example Software: uStatusReg0_t::stVarStatusReg0 Struct Reference

  • Data Structure Index
  • Data Fields
  • uStatusReg0_t
  • stVarStatusReg0
Data Fields
uStatusReg0_t::stVarStatusReg0 Struct Reference

Data Fields

uint32_t | TXPE: 1
uint32_t | TXBOE: 1
uint32_t | TXBUE: 1
uint32_t | RXBOE: 1
uint32_t | LOFE: 1
uint32_t | HDRE: 1
uint32_t | RESETC: 1
uint32_t | PHYINT: 1
uint32_t | TTSCAA: 1
uint32_t | TTSCAB: 1
uint32_t | TTSCAC: 1
uint32_t | TXFCSE: 1
uint32_t | CDPE: 1
uint32_t | RSVD: 19
The documentation for this struct was generated from the following file:
  • NCN26010.c


NCN26010 Example Software: uTCPIPReceiveBuffer_t Union Reference

  • Data Structure Index
  • Data Fields
Data Fields
uTCPIPReceiveBuffer_t Union Reference

Data Fields

uint8_t | receiveBuffer [MAX_RCA_VALUE *(MAX_PAYLOAD_BYTE+HEADER_FOOTER_SIZE)]
uint8_t | receiveBufferInChunks [MAX_RCA_VALUE][(MAX_PAYLOAD_BYTE+HEADER_FOOTER_SIZE)]
The documentation for this union was generated from the following file:
  • NCN26010.c


NCN26010 Example Software: Data Structure Index

  • Data Structure Index
  • Data Fields
Data Structure Index
A | S | T | U
A
ARP_Header
S
stBulkDataTransfer_t
stControlCmdReg_t
stDataReceive_t
stDataTransfer_t
stEthernetFrame_t
uCommandHeaderFooter_t::stHeadFootBits
stRemoteConfigurationCommand_t
uDataHeaderFooter_t::stRxFooterBits
uDataHeaderFooter_t::stTxHeadBits
uStatusReg0_t::stVarStatusReg0
T
timestampFIFO_t
U
uCommandHeaderFooter_t
uDataHeaderFooter_t
uStatusReg0_t
uTCPIPReceiveBuffer_t


NCN26010 Example Software: Data Fields

  • Data Structure Index
  • Data Fields
  • All
  • Variables
Here is a list of all documented struct and union fields with links to the struct/union documentation for each field:
  • Destination : ARP_Header
  • Hardware_Size : ARP_Header
  • Opcode : ARP_Header
  • Protocol_Size : ARP_Header
  • Sender_IP_address : ARP_Header
  • Sender_MAC_address : ARP_Header
  • Source : ARP_Header


NCN26010 Example Software: Data Fields - Variables

  • Data Structure Index
  • Data Fields
  • All
  • Variables
  • Destination : ARP_Header
  • Hardware_Size : ARP_Header
  • Opcode : ARP_Header
  • Protocol_Size : ARP_Header
  • Sender_IP_address : ARP_Header
  • Sender_MAC_address : ARP_Header
  • Source : ARP_Header


NCN26010 Example Software: File List

  • File List
  • Globals
File List
Here is a list of all documented files with brief descriptions:
app.c | Main application file for FreeRTOS NCN26010 Ethernet demo for RSL10
app.h | Main application header file for FreeRTOS NCN26010 Ethernet demo for RSL10
lwipopts.h |
NCN26010.c | : Support functions to simplify utilization of NCN26010 Features
NCN26010.h | Support functions to simplify utilization of NCN26010 Features
Network_interface.h |
Network_transport_layer.h | : Header for Network_transport_layer.c
T1S_FreeRTOS_OS.c | Defines function prototypes for OS specific functions required by NCN26010
T1S_FreeRTOS_TCP-IP.c | Defines function prototypes for interfacing with the TCP/IP layers of the network stack
T1S_Hardware.h | Defines function prototypes for hardware specific functions required by NCN26010
T1S_LWIPTCP-IP.c | Defines function prototypes for interfacing with the TCP/IP layers of the network stack
T1S_OS.h | Defines function prototypes for operating system specific functions required by NCN26010
T1S_RSL10Hardware.c | This application file includes DMA SPI communication related API calls required to communicate with NCN26010
T1S_TCP-IP.h | Defines function prototypes for interfacing with the TCP/IP layers of the network stack


NCN26010 Example Software: app.c File Reference

Functions
app.c File Reference

Main application file for FreeRTOS NCN26010 Ethernet demo for RSL10. More...

#include <app.h>
#include <NCN26010.h>
#include "T1S_OS.h"

Functions

void | Initialize (void)
Initialize the system by disabling interrupts, configuring the required clock settings, and enabling UART prints. More...
int | main (void)
Initialize the system, Initialize NCN26010 and start FreeRTOS. More...

Detailed Description

Main application file for FreeRTOS NCN26010 Ethernet demo for RSL10.

10Base-T1S MACPHY - NCN26010

$Rev: $ $Date:$

Copyright
(c) 2022 ON Semiconductor. All rights reserved. ON Semiconductor is supplying this software for use with ON Semiconductor ethernet products only.

THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

Function Documentation

◆ Initialize()

void Initialize ( void )

Initialize the system by disabling interrupts, configuring the required clock settings, and enabling UART prints.

Returns
None.

◆ main()

int main ( void )

Initialize the system, Initialize NCN26010 and start FreeRTOS.

Returns
None.


NCN26010 Example Software: app.h File Reference

Macros | Functions
app.h File Reference

Main application header file for FreeRTOS NCN26010 Ethernet demo for RSL10. More...

#include <RTE_Components.h>
#include <cmsis_os2.h>
#include <printf.h>

Go to the source code of this file.

Macros

#define RECOVERY_DIO 12

Functions

void Initialize (void)
Initialize the system by disabling interrupts, configuring the required clock settings, and enabling UART prints. More...

Detailed Description

Main application header file for FreeRTOS NCN26010 Ethernet demo for RSL10.

10Base-T1S MACPHY - NCN26010

$Rev: $ $Date:$

Copyright
(c) 2022 ON Semiconductor. All rights reserved. ON Semiconductor is supplying this software for use with ON Semiconductor ethernet products only.

THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

Function Documentation

◆ Initialize()

void Initialize ( void )

Initialize the system by disabling interrupts, configuring the required clock settings, and enabling UART prints.

\Initialize the system by disabling interrupts, configuring the required clock settings, and enabling UART prints.

Returns
None.
None.


NCN26010 Example Software: lwipopts.h Source File

lwipopts.h
1
19#ifndef __LWIPOPTS_H__
20#define __LWIPOPTS_H__
21
26#define NO_SYS 1
27
33#define SYS_LIGHTWEIGHT_PROT 0
34
35/* ---------- Memory options ---------- */
36/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
37 lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
38 byte alignment -> define MEM_ALIGNMENT to 2. */
39#define MEM_ALIGNMENT 4
40
41/* MEM_SIZE: the size of the heap memory. If the application will send
42a lot of data that needs to be copied, this should be set high. */
43#define MEM_SIZE (13*1024)
44
45/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
46 sends a lot of data out of ROM (or other static memory), this
47 should be set high. */
48#define MEMP_NUM_PBUF 10
49/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
50 per active UDP "connection". */
51#define MEMP_NUM_UDP_PCB 6
52/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
53 connections. */
54#define MEMP_NUM_TCP_PCB 13
55/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
56 connections. */
57#define MEMP_NUM_TCP_PCB_LISTEN 6
58/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
59 segments. */
60#define MEMP_NUM_TCP_SEG 8
61/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
62 timeouts. */
63#define MEMP_NUM_SYS_TIMEOUT 10
64
65
66/* ---------- Pbuf options ---------- */
67/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
68#define PBUF_POOL_SIZE 8
69
70/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
71#define PBUF_POOL_BUFSIZE 1524
72
73
74/* ---------- TCP options ---------- */
75#define LWIP_TCP 1
76#define TCP_TTL 255
77
78/* Controls if TCP should queue segments that arrive out of
79 order. Define to 0 if your device is low on memory. */
80#define TCP_QUEUE_OOSEQ 0
81
82/* TCP Maximum segment size. */
83#define TCP_MSS (1500 - 40) /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */
84
85/* TCP sender buffer space (bytes). */
86#define TCP_SND_BUF (4*TCP_MSS)
87
88/* TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
89 as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */
90
91#define TCP_SND_QUEUELEN (2* TCP_SND_BUF/TCP_MSS)
92
93/* TCP receive window. */
94#define TCP_WND (2*TCP_MSS)
95
96
97/* ---------- ICMP options ---------- */
98#define LWIP_ICMP 1
99
100
101/* ---------- DHCP options ---------- */
102#define LWIP_DHCP 1
103
104
105/* ---------- UDP options ---------- */
106#define LWIP_UDP 1
107#define UDP_TTL 255
108
109
110/* ---------- Statistics options ---------- */
111#define LWIP_STATS 0
112
113/* ---------- link callback options ---------- */
114/* LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface
115 * whenever the link changes (i.e., link down)
116 */
117#define LWIP_NETIF_LINK_CALLBACK 1
118
119/*
120 --------------------------------------
121 ---------- Checksum options ----------
122 --------------------------------------
123*/
124
125/*
126The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums by hardware:
127 - To use this feature let the following define uncommented.
128 - To disable it and process by CPU comment the the checksum.
129*/
130#define CHECKSUM_BY_HARDWARE 1
131
132
133#ifdef CHECKSUM_BY_HARDWARE
134 /* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/
135 #define CHECKSUM_GEN_IP 1
136 /* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/
137 #define CHECKSUM_GEN_UDP 0
138 /* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/
139 #define CHECKSUM_GEN_TCP 1
140 /* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/
141 #define CHECKSUM_CHECK_IP 0
142 /* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/
143 #define CHECKSUM_CHECK_UDP 0
144 /* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/
145 #define CHECKSUM_CHECK_TCP 1
146 /* CHECKSUM_CHECK_ICMP==0: Check checksums by hardware for incoming ICMP packets.*/
147 #define CHECKSUM_GEN_ICMP 1
148#else
149 /* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/
150 #define CHECKSUM_GEN_IP 1
151 /* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/
152 #define CHECKSUM_GEN_UDP 1
153 /* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/
154 #define CHECKSUM_GEN_TCP 1
155 /* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/
156 #define CHECKSUM_CHECK_IP 1
157 /* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/
158 #define CHECKSUM_CHECK_UDP 1
159 /* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/
160 #define CHECKSUM_CHECK_TCP 1
161 /* CHECKSUM_CHECK_ICMP==1: Check checksums by hardware for incoming ICMP packets.*/
162 #define CHECKSUM_GEN_ICMP 1
163#endif
164
165
166/*
167 ----------------------------------------------
168 ---------- Sequential layer options ----------
169 ----------------------------------------------
170*/
174#define LWIP_NETCONN 0
175/*
176 ------------------------------------
177 ---------- Socket options ----------
178 ------------------------------------
179*/
183#define LWIP_SOCKET 0
184
185/*
186 ------------------------------------
187 ---------- httpd options ----------
188 ------------------------------------
189*/
190
192#define LWIP_HTTPD_CGI 1
193
195#define LWIP_HTTPD_SSI 1
196
199#define HTTPD_USE_CUSTOM_FSDATA 1
200
201#endif /* __LWIPOPTS_H__ */
202
203/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
204
205#if 0
206//OLD lwipopts.h
207#ifndef __LWIPOPTS_H__
208#define __LWIPOPTS_H__
209
210#define NO_SYS 1
211#define MEM_LIBC_MALLOC 1
212#define MEMP_MEM_MALLOC 1
213#define MEM_ALIGNMENT 4
214#define MEM_SIZE (4 * 1024 * 1024)
215#define MEMP_NUM_PBUF 1024
216#define MEMP_NUM_UDP_PCB 20
217#define MEMP_NUM_TCP_PCB 20
218#define MEMP_NUM_TCP_PCB_LISTEN 16
219#define MEMP_NUM_TCP_SEG 128
220#define MEMP_NUM_REASSDATA 32
221#define MEMP_NUM_ARP_QUEUE 10
222#define PBUF_POOL_SIZE 512
223#define LWIP_ARP 1
224#define IP_REASS_MAX_PBUFS 64
225#define IP_FRAG_USES_STATIC_BUF 0
226#define IP_DEFAULT_TTL 255
227#define IP_SOF_BROADCAST 1
228#define IP_SOF_BROADCAST_RECV 1
229#define LWIP_ICMP 1
230#define LWIP_BROADCAST_PING 1
231#define LWIP_MULTICAST_PING 1
232#define LWIP_RAW 1
233#define TCP_WND (4 * TCP_MSS)
234#define TCP_MSS 1460
235#define TCP_SND_BUF (8 * TCP_MSS)
236#define TCP_LISTEN_BACKLOG 1
237#define LWIP_NETIF_STATUS_CALLBACK 1
238#define LWIP_NETIF_LINK_CALLBACK 1
239#define LWIP_NETIF_HWADDRHINT 1
240#define LWIP_NETCONN 0
241#define LWIP_SOCKET 0
242#define LWIP_STATS_DISPLAY 1
243#define MEM_STATS 0
244#define SYS_STATS 0
245#define SYS_LIGHTWEIGHT_PROT 0
246#define MEMP_STATS 0
247#define LINK_STATS 0
248#define ETHARP_TRUST_IP_MAC 0
249#define ETH_PAD_SIZE 0
250#define LWIP_CHKSUM_ALGORITHM 2
251
252
253#define LWIP_TCP_KEEPALIVE 1
254
255// Keepalive values, compliant with RFC 1122. Don't change this unless you know what you're doing
256#define TCP_KEEPIDLE_DEFAULT 10000UL // Default KEEPALIVE timer in milliseconds
257#define TCP_KEEPINTVL_DEFAULT 2000UL // Default Time between KEEPALIVE probes in milliseconds
258#define TCP_KEEPCNT_DEFAULT 9U // Default Counter for KEEPALIVE probes
259
260#define LWIP_DEBUG 0
261
262#define ETHARP_DEBUG LWIP_DBG_OFF
263#define NETIF_DEBUG LWIP_DBG_OFF
264#define PBUF_DEBUG LWIP_DBG_OFF
265#define API_LIB_DEBUG LWIP_DBG_OFF
266#define API_MSG_DEBUG LWIP_DBG_OFF
267#define SOCKETS_DEBUG LWIP_DBG_OFF
268#define ICMP_DEBUG LWIP_DBG_OFF
269#define INET_DEBUG LWIP_DBG_OFF
270#define IP_DEBUG LWIP_DBG_OFF
271#define IP_REASS_DEBUG LWIP_DBG_OFF
272#define RAW_DEBUG LWIP_DBG_OFF
273#define MEM_DEBUG LWIP_DBG_OFF
274#define MEMP_DEBUG LWIP_DBG_OFF
275#define SYS_DEBUG LWIP_DBG_OFF
276#define TCP_DEBUG LWIP_DBG_OFF
277#define TCP_INPUT_DEBUG LWIP_DBG_OFF
278#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
279#define TCP_RTO_DEBUG LWIP_DBG_OFF
280#define TCP_CWND_DEBUG LWIP_DBG_OFF
281#define TCP_WND_DEBUG LWIP_DBG_OFF
282#define TCP_FR_DEBUG LWIP_DBG_OFF
283#define TCP_QLEN_DEBUG LWIP_DBG_OFF
284#define TCP_RST_DEBUG LWIP_DBG_OFF
285#define UDP_DEBUG LWIP_DBG_OFF
286#define TCPIP_DEBUG LWIP_DBG_OFF
287#define PPP_DEBUG LWIP_DBG_OFF
288#define SLIP_DEBUG LWIP_DBG_OFF
289#define DHCP_DEBUG LWIP_DBG_OFF
290
291#endif /* __LWIPOPTS_H__ */
292#endif //END OLDWLIP.h


NCN26010 Example Software: NCN26010.c File Reference

Data Structures | Macros | Enumerations | Functions | Variables
NCN26010.c File Reference

: Support functions to simplify utilization of NCN26010 Features More...

#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <unistd.h>
#include <string.h>
#include "NCN26010.h"
#include "T1S_Hardware.h"
#include "T1S_TCP-IP.h"
#include "T1S_OS.h"

Data Structures

union | uCommandHeaderFooter_t
struct | uCommandHeaderFooter_t::stHeadFootBits
union | uDataHeaderFooter_t
struct | uDataHeaderFooter_t::stTxHeadBits
struct | uDataHeaderFooter_t::stRxFooterBits
struct | stControlCmdReg_t
struct | stDataReceive_t
struct | stDataTransfer_t
struct | stBulkDataTransfer_t
struct | stEthernetFrame_t
union | uTCPIPReceiveBuffer_t
union | uStatusReg0_t
struct | uStatusReg0_t::stVarStatusReg0
struct | timestampFIFO_t

Macros

#define | MAX_CONTROL_CMD_LEN (uint8_t)(0x7F)
#define | HEADER_FOOTER_SIZE (uint8_t)4
#define | MAX_REG_DATA_ONECONTROLCMD (uint8_t)(MAX_CONTROL_CMD_LEN * EACH_REG_SIZE)
#define | MESSAGETYPE_SEND (uint8_t)0
#define | MESSAGETYPE_RESPONSE (uint8_t)1
#define | CONFIGTYPE_REGREAD (uint8_t)0
#define | CONFIGTYPE_REGWRITE (uint8_t)1
#define | ETHERNET_HEADER_SIZE (uint8_t)14
#define | ETHERNET_TYPE_MACPHYCONFIG (uint16_t)0x0909
#define | MAX_RCA_VALUE (uint8_t)31
#define | CONFIG_FILE_MAXLINE_LEN (uint8_t)50
#define | FCS_POLYNOMIAL (uint32_t)0xEDB88320
#define | SIZE_OF_FCS (uint8_t)4
#define | PLCA_REG_ENABLED (uint32_t)0b1 << 15
#define | PLCA_REG_DISABLED (uint32_t)0
#define | PRINTF(fmt, ...)

Enumerations

enum | DNC_COMMANDTYPE { DNC_COMMANDTYPE_CONTROL = 0 , DNC_COMMANDTYPE_DATA }
enum | REG_ADDR_INCREMENT { REG_ADDR_INCREMENT_ENABLE = 0 , REG_ADDR_INCREMENT_DISABLE }
enum | REG_COMMAND_TYPE { REG_COMMAND_TYPE_READ = 0 , REG_COMMAND_TYPE_WRITE }

Functions

uint32_t | ConfigureMACPHY (void)
void | CheckIfFCSEnabled (void)
uint32_t | FCS_Calculator (const uint8_t *p_data, uint16_t dataSize)
bool | GetParity (uint32_t valueToCalculateParity)
void | ConvertEndianness (uint32_t valueToConvert, uint32_t *convertedValue)
bool | T1S_WriteMACPHYReg (stControlCmdReg_t *p_regData)
bool | T1S_ReadMACPHYReg (stControlCmdReg_t *p_regInfoInput, stControlCmdReg_t *p_readRegData)
uint32_t | T1S_ClearStatus (void)
Reads and clears the NCN26010 status register (MMS 0, 0x8). More...
uint32_t | T1S_Receive (stDataReceive_t *p_dataReceiveInfo, uint16_t num_chunks_to_collect)
uint32_t | CheckRCABuffAndReceiveData (bool readTCPIPDataState)
void | T1S_RemoteRegWrite (uint8_t *mac_addr, uint8_t mms, uint16_t reg_address, uint32_t regValueToWrite)
void | T1S_RemoteRegRead (uint8_t *mac_addr, uint8_t mms, uint16_t reg_address)
void | T1S_InterpretEthernetTypeFrame (uint8_t *receiveMACPHYBuff, stEthernetFrame_t stVarEthernetFrame)
__attribute__ ((weak))
void | DataReadyCallback (uint32_t tick)
uint32_t | NCN26010_Init (void)
uint32_t | get_internal_MAC_address (uint8_t *MAC_address)
uint32_t | T1S_RegRead (uint8_t MMS, uint16_t Address)
Reads a register on the NCN26010 over SPI. More...
uint32_t | T1S_RegWrite (uint8_t MMS, uint16_t Address, uint32_t data)
Writes a register on the NCN26010 over SPI. More...
uint32_t | T1S_Transmit (uint8_t *p_tcpipDataBuffer, uint16_t num_bytes_to_transmit)
Assenbles txBuffer into chunks and transfers then to the NCN26010 to be trasmitted over T1S. More...
void | ReadBufferStatusReg (void)
uint32_t | NCN26010_Loop (void)
Endless loop to retrieve data from NCN26010 to the TCP/IP stack and vice versa. Calls OS_WaitUntilISR between each iteration to support event driven realtime operation. More...
uint32_t | NCN26010_Exit ()
Sets a flag to cause NCN26010_Loop to exit after the next iteration. More...
uint32_t | T1S_ConfigurePLCA (uint8_t id, uint8_t max_id, bool mode)
Saves configuration options for Physical Layer Colision Avoidance. Must be called before NCN26010_Init. More...
uint32_t | T1S_SendRemoteConfiguration (uint8_t *targetMAC, stRemoteConfigurationCommand_t *commands, uint32_t numCommands)

Variables

uint8_t | g_topoMACAddrReceived [SIZE_OF_MAC_ADDR] = {0}
uint8_t | g_maxPayloadSize
uint8_t | g_transmitCreditsAvailable_TXC = 0
const uint8_t | g_broadCastMACAddr [SIZE_OF_MAC_ADDR] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}

Detailed Description

: Support functions to simplify utilization of NCN26010 Features

Author
: Manjunath H M, Arndt Schuebel, Kyle Storey $Rev: $
Date
Copyright
(c) 2021 ON Semiconductor. All rights reserved. ON Semiconductor is supplying this software for use with ON Semiconductor ethernet products only.

THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

Function Documentation

◆ ConvertEndianness()

void ConvertEndianness | ( | uint32_t | valueToConvert,
 |  | uint32_t * | convertedValue
 | ) |  |

cast and copy an uint32_t to a uint8_t array

swap bytes in this uint8_t array

◆ NCN26010_Exit()

uint32_t NCN26010_Exit ( )

Sets a flag to cause NCN26010_Loop to exit after the next iteration.

Returns
OK.

◆ NCN26010_Init()

uint32_t NCN26010_Init ( void )

< Enables interrupt to check if any data to be read and assigns its ISR callback

◆ NCN26010_Loop()

uint32_t NCN26010_Loop ( )

Endless loop to retrieve data from NCN26010 to the TCP/IP stack and vice versa. Calls OS_WaitUntilISR between each iteration to support event driven realtime operation.

Returns
OK only after NCN26010_Exit is called.

◆ T1S_ClearStatus()

uint32_t T1S_ClearStatus ( )

Reads and clears the NCN26010 status register (MMS 0, 0x8).

Returns
OK if the status is now STATUS_OK. Otherwise the value of the status register.

◆ T1S_ConfigurePLCA()

uint32_t T1S_ConfigurePLCA | ( | uint8_t | id,
 |  | uint8_t | max_id,
 |  | bool | enabled
 | ) |  |

Saves configuration options for Physical Layer Colision Avoidance. Must be called before NCN26010_Init.

Parameters
id | The PLCA id, which determinses the order in the round robin. If 0 then this node is the PLCA leader.
max_id | The maximum PLCA id, ignored if id != 0, determines the number of nodes on the same segment.
enabled | If true the part will be configured in PLCA mode. Otherwise id and max_id are igonored.
Returns
OK after internal varialbes have been set.

◆ T1S_Receive()

uint32_t T1S_Receive | ( | stDataReceive_t * | p_dataReceiveInfo,
 |  | uint16_t | num_chunks_to_collect
 | ) |  |

Total required chunks is 31(31 x 64) but kept one extra chunk bytes added extra to buffer so total 32x64

< If Ethernet Type is 0x0909 that is Configuration Ethernet frame

< Only if addressed to this device or if broadcast configuration for all nodes

◆ T1S_RegRead()

uint32_t T1S_RegRead | ( | uint8_t | MMS,
 |  | uint16_t | address
 | ) |  |

Reads a register on the NCN26010 over SPI.

Parameters
MMS | The memory map selector of the register to be read.
address | The address of the register to be read.
Returns
The value of the requested register.

◆ T1S_RegWrite()

uint32_t T1S_RegWrite | ( | uint8_t | MMS,
 |  | uint16_t | address,
 |  | uint32_t | data
 | ) |  |

Writes a register on the NCN26010 over SPI.

Parameters
MMS | The memory map selector of the register to be written.
address | The address of the register to be written.
Returns
The value written as echoed by the NCN26010 over SPI

◆ T1S_Transmit()

uint32_t T1S_Transmit | ( | uint8_t * | txBuffer,
 |  | uint16_t | num_bytes_to_transmit
 | ) |  |

Assenbles txBuffer into chunks and transfers then to the NCN26010 to be trasmitted over T1S.

Parameters
txBuffer | A pointer to where the data to be transfered is stored.
num_bytes_to_transmit | The number of bytes in txBuffer to transmit.
Returns
OK if data transfered to NCN26010 successfully. An error code indicating what went wront otherwise.

Total required chunks is 31(31 x 64) but kept one extra chunk bytes added extra to buffer so total 32x64


NCN26010 Example Software: NCN26010.h File Reference

Data Structures | Macros | Functions | Variables
NCN26010.h File Reference

Support functions to simplify utilization of NCN26010 Features. More...

#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct stRemoteConfigurationCommand_t

Macros

#define | REMOTE_CONFIGURATION_ENABLED 1
#define | PLCA_ENABLED (bool) false
#define | PLCA_ROLE (bool) false
#define | PLCA_ID_INIT (uint8_t) 0
#define | PLCA_NODE_COUNT (uint8_t) 4
#define | ENI_ENABLED (bool) false
#define | POLLING 0
#define | USE_INTERNAL_MAC_ADDRESS 1
#define | MAC_PROMISCUOUS_MODE 0
#define | DEFAULT_MAC_ADDRESS {0x60, 0xC0, 0xBF, 0x01, 0x01, 0x01}
#define | DEFAULT_IP_ADDRESS_ARRAY {192, 1, 1, 1}
#define | DEFAULT_IP_ADDRESS 0x010101c0
#define | MAX_PAYLOAD_BYTE (uint8_t) 64
#define | EACH_REG_SIZE (uint8_t) 4
#define | MAX_REG_DATA_ONECHUNK (uint8_t) (MAX_PAYLOAD_BYTE/EACH_REG_SIZE)
#define | MAX_DATA_DWORD_ONECHUNK MAX_REG_DATA_ONECHUNK
#define | HEADER_FOOTER_SIZE (uint8_t)4
#define | STATUS_OK(status) (uint8_t)(((status) & 0xFFFFFFF7) == 0x00000000)
#define | SIZE_OF_MAC_ADDR (uint8_t)6
#define | ENABLE_MAC_FILTER (uint32_t)1 << 31
#define | OK (uint32_t) 0
#define | UNKNOWN_ERROR (uint32_t) 1
#define | PHYSICAL_COLLISSION_ERROR 2
#define | PLCA_RECOVERY_ERROR 3
#define | REMOTE_JABBER_ERROR 4
#define | LOCAL_JABBER_ERROR 5
#define | RX_BUFFER_OVERFLOW_ERROR 6
#define | TX_BUFFER_OVERFLOW_ERROR 7
#define | TX_BUFFER_UNDERFLOW_ERROR 8
#define | REGISTER_READ_ERROR 9
#define | INIT_ERROR 10
#define | SIZE_OF_MAC_ADDR (uint8_t)6

Functions

uint32_t | T1S_ConfigurePLCA (uint8_t id, uint8_t max_id, bool enabled)
Saves configuration options for Physical Layer Colision Avoidance. Must be called before NCN26010_Init. More...
uint32_t | NCN26010_Init ()
uint32_t | NCN26010_Loop ()
Endless loop to retrieve data from NCN26010 to the TCP/IP stack and vice versa. Calls OS_WaitUntilISR between each iteration to support event driven realtime operation. More...
uint32_t | T1S_Transmit (uint8_t *txBuffer, uint16_t num_bytes_to_transmit)
Assenbles txBuffer into chunks and transfers then to the NCN26010 to be trasmitted over T1S. More...
uint32_t | T1S_RegRead (uint8_t MMS, uint16_t address)
Reads a register on the NCN26010 over SPI. More...
uint32_t | T1S_RegWrite (uint8_t MMS, uint16_t address, uint32_t data)
Writes a register on the NCN26010 over SPI. More...
uint32_t | T1S_SendRemoteConfiguration (uint8_t targetMAC[SIZE_OF_MAC_ADDR], stRemoteConfigurationCommand_t *commands, uint32_t numCommands)
Reads or writes registers of a remote NCN26010. May be disbled by defining REMOTE_CONFIGURATION_ENABLED to be false. More...
uint32_t | T1S_ClearStatus ()
Reads and clears the NCN26010 status register (MMS 0, 0x8). More...
uint32_t | NCN26010_Exit ()
Sets a flag to cause NCN26010_Loop to exit after the next iteration. More...

Variables

uint8_t g_currentNodeMACAddr [SIZE_OF_MAC_ADDR]

Detailed Description

Support functions to simplify utilization of NCN26010 Features.

Configures the NCN26010 as defined in, Configures Interrupt Routines and initializes SPI, TCP/IP, and (if applicable) OS specific code.

Author
Arndt Schuebel, Kyle Storey. $Rev: $
Date
Copyright
(c) 2022 ON Semiconductor. All rights reserved. ON Semiconductor is supplying this software for use with ON Semiconductor ethernet products only.

THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

Returns
OK if successfully initalized of all module, INIT_ERROR otherwise.

Function Documentation

◆ NCN26010_Exit()

uint32_t NCN26010_Exit ( )

Sets a flag to cause NCN26010_Loop to exit after the next iteration.

Returns
OK.

◆ NCN26010_Init()

uint32_t NCN26010_Init ( )

< Enables interrupt to check if any data to be read and assigns its ISR callback

◆ NCN26010_Loop()

uint32_t NCN26010_Loop ( )

Endless loop to retrieve data from NCN26010 to the TCP/IP stack and vice versa. Calls OS_WaitUntilISR between each iteration to support event driven realtime operation.

Returns
OK only after NCN26010_Exit is called.

◆ T1S_ClearStatus()

uint32_t T1S_ClearStatus ( )

Reads and clears the NCN26010 status register (MMS 0, 0x8).

Returns
OK if the status is now STATUS_OK. Otherwise the value of the status register.

◆ T1S_ConfigurePLCA()

uint32_t T1S_ConfigurePLCA | ( | uint8_t | id,
 |  | uint8_t | max_id,
 |  | bool | enabled
 | ) |  |

Saves configuration options for Physical Layer Colision Avoidance. Must be called before NCN26010_Init.

Parameters
id | The PLCA id, which determinses the order in the round robin. If 0 then this node is the PLCA leader.
max_id | The maximum PLCA id, ignored if id != 0, determines the number of nodes on the same segment.
enabled | If true the part will be configured in PLCA mode. Otherwise id and max_id are igonored.
Returns
OK after internal varialbes have been set.

◆ T1S_RegRead()

uint32_t T1S_RegRead | ( | uint8_t | MMS,
 |  | uint16_t | address
 | ) |  |

Reads a register on the NCN26010 over SPI.

Parameters
MMS | The memory map selector of the register to be read.
address | The address of the register to be read.
Returns
The value of the requested register.

◆ T1S_RegWrite()

uint32_t T1S_RegWrite | ( | uint8_t | MMS,
 |  | uint16_t | address,
 |  | uint32_t | data
 | ) |  |

Writes a register on the NCN26010 over SPI.

Parameters
MMS | The memory map selector of the register to be written.
address | The address of the register to be written.
Returns
The value written as echoed by the NCN26010 over SPI

◆ T1S_SendRemoteConfiguration()

uint32_t T1S_SendRemoteConfiguration | ( | uint8_t | targetMAC[SIZE_OF_MAC_ADDR],
 |  | stRemoteConfigurationCommand_t * | commands,
 |  | uint32_t | numCommands
 | ) |  |

Reads or writes registers of a remote NCN26010. May be disbled by defining REMOTE_CONFIGURATION_ENABLED to be false.

Parameters
commands | An array of stRemoteConfigurationCommand_t to send to the remote device.
address | The address of the register to be written.
Returns
The value written as echoed by the NCN26010 over SPI

◆ T1S_Transmit()

uint32_t T1S_Transmit | ( | uint8_t * | txBuffer,
 |  | uint16_t | num_bytes_to_transmit
 | ) |  |

Assenbles txBuffer into chunks and transfers then to the NCN26010 to be trasmitted over T1S.

Parameters
txBuffer | A pointer to where the data to be transfered is stored.
num_bytes_to_transmit | The number of bytes in txBuffer to transmit.
Returns
OK if data transfered to NCN26010 successfully. An error code indicating what went wront otherwise.

Total required chunks is 31(31 x 64) but kept one extra chunk bytes added extra to buffer so total 32x64


NCN26010 Example Software: Network_interface.h Source File

Network_interface.h
1/* USER CODE BEGIN Header */
12/* USER CODE END Header */
13
14/* Define to prevent recursive inclusion -------------------------------------*/
15#ifndef __NETWORK_INTERFACE_H
16#define __NETWORK_INTERFACE_H
17
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/* Includes ------------------------------------------------------------------*/
24#include "lwip/tcpip.h"
25#include "lwip/ip_addr.h"
26#include "lwip/err.h"
27#include "lwip/pbuf.h"
28#include "lwip/tcpbase.h"
29#include "lwip/debug.h"
30#include "lwip/stats.h"
31#include "lwip/tcp.h"
32#include "lwip/pbuf.h"
33#include "lwip/etharp.h"
34#include "lwip/prot/ethernet.h"
35#include "Network_transport_layer.h"
36#include "netif/ethernet.h"
37#include "SPI_OA.h"
38
39#define IFNAME0 'T'
40#define IFNAME1 '1'
41
42#define ETH_MAX_PACKET_SIZE ((uint32_t)1528U)
43#define ETH_HEADER ((uint32_t)14U)
44#define ETH_CRC ((uint32_t)4U)
45#define ETH_VLAN_TAG ((uint32_t)4U)
46#define ETH_MIN_PAYLOAD ((uint32_t)46U)
47#define ETH_MAX_PAYLOAD ((uint32_t)1500U)
48#define ETH_JUMBO_FRAME_PAYLOAD ((uint32_t)9000U)
50//define MAC Address 60:c0:bf:01:01:05
51#define ETH_MAC_ADDR0 0x05
52#define ETH_MAC_ADDR1 0x01
53#define ETH_MAC_ADDR2 0x01
54#define ETH_MAC_ADDR3 0xbf
55#define ETH_MAC_ADDR4 0xc0
56#define ETH_MAC_ADDR5 0x60
57
61struct ARP_Header
62{
63
64 uint16_t Destination[3];
66 uint16_t Source[3];
68 uint32_t EtherType;
69
70 uint32_t Hardware_Type ;
71
72 uint32_t Protocol_Type ;
73
74 uint32_t Hardware_Size ;
76 uint32_t Protocol_Size;
78 uint32_t Opcode ;
81 uint32_t Sender_MAC_address;
83 uint32_t Sender_IP_address;
85 uint32_t Target_MAC_address ;
86
87 uint32_t Target_IPaddress ;
88
89};
90
91/*#define ETH_MAC_ADDR0 0x0103
92#define ETH_MAC_ADDR1 0xbf01
93#define ETH_MAC_ADDR2 0x60c0 */
94
95void Netif_Config(void);
96void low_level_init(struct netif *netif);
97err_t ethernetif_init(struct netif *netif);
98err_t ethernet_output_T1S_IP(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr);
99err_t ethernet_output_T1S_ARP(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr);
100
101err_t low_level_output2();
102extern struct netif gnetif;
103
104
105
106#endif
Network_transport_layer.h
: Header for Network_transport_layer.c
ARP_Header
Header for ARP.
Definition: Network_interface.h:62
ARP_Header::Protocol_Size
uint32_t Protocol_Size
Definition: Network_interface.h:76
ARP_Header::Hardware_Size
uint32_t Hardware_Size
Definition: Network_interface.h:74
ARP_Header::Opcode
uint32_t Opcode
Definition: Network_interface.h:78
ARP_Header::Sender_IP_address
uint32_t Sender_IP_address
Definition: Network_interface.h:83
ARP_Header::Destination
uint16_t Destination[3]
Definition: Network_interface.h:64
ARP_Header::Sender_MAC_address
uint32_t Sender_MAC_address
Definition: Network_interface.h:81
ARP_Header::Source
uint16_t Source[3]
Definition: Network_interface.h:66


NCN26010 Example Software: Network_transport_layer.h File Reference

Macros
Network_transport_layer.h File Reference

: Header for Network_transport_layer.c More...

#include "lwip/tcpip.h"
#include "lwip/ip_addr.h"
#include "lwip/err.h"
#include "lwip/pbuf.h"
#include "lwip/tcpbase.h"
#include "lwip/debug.h"
#include "lwip/stats.h"
#include "lwip/tcp.h"
#include "lwip/apps/lwiperf.h"

Go to the source code of this file.

Macros

#define USE_DHCP 0 /* enable DHCP, if disabled static address is used */

Detailed Description

: Header for Network_transport_layer.c

Attention


NCN26010 Example Software: T1S_FreeRTOS_OS.c File Reference

Macros | Functions | Variables
T1S_FreeRTOS_OS.c File Reference

Defines function prototypes for OS specific functions required by NCN26010. More...

#include "T1S_OS.h"
#include "FreeRTOS_IP.h"
#include "FreeRTOS_IP_Private.h"
#include "event_groups.h"
#include "FreeRTOS_sockets.h"
#include "ncn26010.h"
#include <printf.h>

Macros

#define BUFFER_SIZE 512

Functions

uint32_t | OS_Init ()
Initialization Callback for OS Code. Called after SPI_Init. More...
void | OS_Start ()
Starts the OS scheduler. Never returns.
uint32_t | OS_WaitUntilISR ()
void | OS_Callback (uint32_t tick)
uint32_t | OS_SetDataReadyCallback (ISR_t callback)
Coordinates with hardware to call callback when the NCN26010 signals that data is available. Intended to allow the OS to observe these events. More...

Variables

EventGroupHandle_t | xEventGroupHandle
StaticEventGroup_t | xCreatedEventGroup

Detailed Description

Defines function prototypes for OS specific functions required by NCN26010.

Author
Kyle Storey, Tejashree Chaudhari. $Rev: $
Date
Copyright
(c) 2022 ON Semiconductor. All rights reserved. ON Semiconductor is supplying this software for use with ON Semiconductor ethernet products only.

THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

Function Documentation

◆ OS_Init()

uint32_t OS_Init ( )

Initialization Callback for OS Code. Called after SPI_Init.

Returns
OK if successfully initalized, OS_UNKNOWN_ERROR otherwise.

◆ OS_SetDataReadyCallback()

uint32_t OS_SetDataReadyCallback ( ISR_t callback )

Coordinates with hardware to call callback when the NCN26010 signals that data is available. Intended to allow the OS to observe these events.

Parameters
callback A function pointer to ISR_t to call when the interrupt fires.
Returns
OK if the callback is successfully installed.


NCN26010 Example Software: T1S_FreeRTOS_TCP-IP.c File Reference

Functions | Variables
T1S_FreeRTOS_TCP-IP.c File Reference

Defines function prototypes for interfacing with the TCP/IP layers of the network stack. More...

#include "T1S_TCP-IP.h"
#include "FreeRTOS_IP.h"
#include "FreeRTOS_IP_Private.h"
#include "NetworkBufferManagement.h"
#include <printf.h>

Functions

uint32_t | TCPIP_Init ()
Initialization Callback for TCP/IP Code. More...
uint32_t | TCPIP_Receive (uint8_t *buffer, uint16_t number_of_bytes_received)
Transfers data in a buffer into the TCP/IP Stack. More...
uint32_t | TCPIP_PollCallback (uint8_t transmitCreditsAvailable_TXC)
Callback called frequently to allow for the TCPIP code to poll the TCP/IP stack to see if data is available. More...

Variables

uint8_t g_currentNodeMACAddr [SIZE_OF_MAC_ADDR] = DEFAULT_MAC_ADDRESS

Detailed Description

Defines function prototypes for interfacing with the TCP/IP layers of the network stack.

Author
Arndt Schuebel, Kyle Storey. $Rev: $
Date
Copyright
(c) 2022 ON Semiconductor. All rights reserved. ON Semiconductor is supplying this software for use with ON Semiconductor ethernet products only.

THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

Function Documentation

◆ TCPIP_Init()

uint32_t TCPIP_Init ( )

Initialization Callback for TCP/IP Code.

Returns
OK if successfully initalized, TCPIP_UNKNOWN_ERROR otherwise.

◆ TCPIP_PollCallback()

uint32_t TCPIP_PollCallback ( uint8_t transmitCreditsAvailable_TXC )

Callback called frequently to allow for the TCPIP code to poll the TCP/IP stack to see if data is available.

Parameters
transmitCreditsAvailable_TXC The number of available chunks that will fit in NCN26010 buffer.
Returns
OK if no erros occurred, TCPIP_UNKNOWN_ERROR otherwise.

◆ TCPIP_Receive()

uint32_t TCPIP_Receive | ( | uint8_t * | buffer,
 |  | uint16_t | number_of_bytes_received
 | ) |  |

Transfers data in a buffer into the TCP/IP Stack.

Parameters
buffer | A pointer to where the data to be received is stored
number_of_bytes_received | The number of bytes in the buffer to transfer to the TCP/IP stack
Returns
OK if successfully transfered into the TCP/IP stack, TCPIP_UNKNOWN_ERROR otherwise.


NCN26010 Example Software: T1S_Hardware.h File Reference

Macros | Typedefs | Functions
T1S_Hardware.h File Reference

Defines function prototypes for hardware specific functions required by NCN26010. More...

#include <stdint.h>

Go to the source code of this file.

Macros

#define | OK (uint32_t) 0
#define | SPI_ERROR (uint32_t) 1
#define | SPI_INIT_ERROR (uint32_t) 2
#define | ISR_INIT_ERROR (uint32_t) 3

Typedefs

typedef void(* | ISR_t) (uint32_t tick)
typedef void(* | ErrorCallback_t) (uint32_t error)

Functions

uint32_t | SPI_Init ()
Initialization Callback for SPI Code. Must be called before the first SPI_Transfer. More...
uint32_t | SPI_Transfer (uint8_t *rx_buffer, uint8_t *tx_buffer, uint16_t num_bytes_to_transfer)
Transmits and Recieves Data with NCN26010 over a bidirectional SPI interface. More...
uint32_t | SetDataReadyISR (ISR_t callback)
Configures hardware to call callback when the NCN26010 asserts its interrupt. More...
void | DelayMicroseconds (uint32_t microseconds)
Uses hardware timers to delay the requested number of microseconds. More...
uint32_t | GetTick ()
Reads hardware timers to get the current time in milliseconds. More...
uint32_t | SPI_Cleanup ()
Frees SPI module and deinitializes. More...
uint32_t | SleepUntilISR ()
Put MCU in a low power mode that will wait until an interrupt. More...

Detailed Description

Defines function prototypes for hardware specific functions required by NCN26010.

Author
Arndt Schuebel, Kyle Storey. $Rev: $
Date
Copyright
(c) 2022 ON Semiconductor. All rights reserved. ON Semiconductor is supplying this software for use with ON Semiconductor ethernet products only.

THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

Function Documentation

◆ DelayMicroseconds()

void DelayMicroseconds ( uint32_t microseconds )

Uses hardware timers to delay the requested number of microseconds.

Parameters
microseconds The number of microseconds to delay
Returns
OK if returning after the requested number of microseconds.

◆ GetTick()

uint32_t GetTick ( )

Reads hardware timers to get the current time in milliseconds.

Returns
The current time in milliseconds.

◆ SetDataReadyISR()

uint32_t SetDataReadyISR ( ISR_t callback )

Configures hardware to call callback when the NCN26010 asserts its interrupt.

Parameters
callback A function pointer to ISR_t to call when the interrupt fires.
Returns
OK if the interrupt service routine is successfully installed.

◆ SleepUntilISR()

uint32_t SleepUntilISR ( )

Put MCU in a low power mode that will wait until an interrupt.

Returns
OK after the next interrupt if successful.

◆ SPI_Cleanup()

uint32_t SPI_Cleanup ( )

Frees SPI module and deinitializes.

Returns
OK if successfully cleaned up.

◆ SPI_Init()

uint32_t SPI_Init ( )

Initialization Callback for SPI Code. Must be called before the first SPI_Transfer.

Returns
OK if successfully initalized, SPI_INIT_ERROR otherwise.

◆ SPI_Transfer()

uint32_t SPI_Transfer | ( | uint8_t * | rx_buffer,
 |  | uint8_t * | tx_buffer,
 |  | uint16_t | num_bytes_to_transfer
 | ) |  |

Transmits and Recieves Data with NCN26010 over a bidirectional SPI interface.

Parameters
rx_buffer | A pointer to where received data should be placed.
tx_buffer | A pointer to where data to be trasfered is stored.
num_bytes_to_transfer | The number of bytes to send and receive over SPI
Returns
OK if all data successfuly transfered. SPI_ERROR otherwise.


NCN26010 Example Software: T1S_LWIPTCP-IP.c File Reference

Macros | Functions | Variables
T1S_LWIPTCP-IP.c File Reference

Defines function prototypes for interfacing with the TCP/IP layers of the network stack. More...

#include <stdint.h>
#include "T1S_TCP-IP.h"
#include "T1S_Hardware.h"
#include "NCN26010.h"
#include "lwip/init.h"
#include "lwip/stats.h"
#include "lwip/ip6.h"
#include "lwip/ethip6.h"
#include "lwip/etharp.h"
#include "lwip/netif.h"
#include "lwip/timeouts.h"
#include "netif/ethernet.h"
#include <string.h>

Macros

#define | ETHERNET_MTU 1500
#define | MAX_ETH_FRAME_SIZE 1518
#define | DEFAULT_NETMASK 0x00FFFFFF

Functions

uint32_t | TCPIP_Init ()
Initialization Callback for TCP/IP Code. More...
uint32_t | TCPIP_Receive (uint8_t *buffer, uint16_t number_of_bytes_received)
Transfers data in a buffer into the TCP/IP Stack. More...
uint32_t | TCPIP_PollCallback (uint8_t transmitCreditsAvailable_TXC)
Callback called frequently to allow for the TCPIP code to poll the TCP/IP stack to see if data is available. More...
uint32_t | sys_now ()

Variables

uint8_t g_currentNodeMACAddr [SIZE_OF_MAC_ADDR] = DEFAULT_MAC_ADDRESS

Detailed Description

Defines function prototypes for interfacing with the TCP/IP layers of the network stack.

Author
Kyle Storey. $Rev: $ $Date:$
Copyright
(c) 2022 ON Semiconductor. All rights reserved. ON Semiconductor is supplying this software for use with ON Semiconductor ethernet products only.

THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

Function Documentation

◆ TCPIP_Init()

uint32_t TCPIP_Init ( )

Initialization Callback for TCP/IP Code.

Returns
OK if successfully initalized, TCPIP_UNKNOWN_ERROR otherwise.

◆ TCPIP_PollCallback()

uint32_t TCPIP_PollCallback ( uint8_t transmitCreditsAvailable_TXC )

Callback called frequently to allow for the TCPIP code to poll the TCP/IP stack to see if data is available.

Parameters
transmitCreditsAvailable_TXC The number of available chunks that will fit in NCN26010 buffer.
Returns
OK if no erros occurred, TCPIP_UNKNOWN_ERROR otherwise.

◆ TCPIP_Receive()

uint32_t TCPIP_Receive | ( | uint8_t * | buffer,
 |  | uint16_t | number_of_bytes_received
 | ) |  |

Transfers data in a buffer into the TCP/IP Stack.

Parameters
buffer | A pointer to where the data to be received is stored
number_of_bytes_received | The number of bytes in the buffer to transfer to the TCP/IP stack
Returns
OK if successfully transfered into the TCP/IP stack, TCPIP_UNKNOWN_ERROR otherwise.


NCN26010 Example Software: T1S_OS.h File Reference

Macros | Typedefs | Functions
T1S_OS.h File Reference

Defines function prototypes for operating system specific functions required by NCN26010. More...

#include <stdint.h>
#include <T1S_Hardware.h>

Go to the source code of this file.

Macros

#define | OK (uint32_t) 0
#define | OS_UNKNOWN_ERROR (uint32_t) 1

Typedefs

typedef void(* ISR_t) (uint32_t tick)

Functions

uint32_t | OS_Init ()
Initialization Callback for OS Code. Called after SPI_Init. More...
void | OS_Start ()
Starts the OS scheduler. Never returns.
uint32_t | OS_WaitUntilDataReady ()
Yeilds CPU to other tasks until NCN26010 signals that data is available. More...
uint32_t | OS_SetDataReadyCallback (ISR_t callback)
Coordinates with hardware to call callback when the NCN26010 signals that data is available. Intended to allow the OS to observe these events. More...

Detailed Description

Defines function prototypes for operating system specific functions required by NCN26010.

Author
Kyle Storey, Tejashree Chaudhari. $Rev: $
Date
Copyright
(c) 2022 ON Semiconductor. All rights reserved. ON Semiconductor is supplying this software for use with ON Semiconductor ethernet products only.

THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

Function Documentation

◆ OS_Init()

uint32_t OS_Init ( )

Initialization Callback for OS Code. Called after SPI_Init.

Returns
OK if successfully initalized, OS_UNKNOWN_ERROR otherwise.

◆ OS_SetDataReadyCallback()

uint32_t OS_SetDataReadyCallback ( ISR_t callback )

Coordinates with hardware to call callback when the NCN26010 signals that data is available. Intended to allow the OS to observe these events.

Parameters
callback A function pointer to ISR_t to call when the interrupt fires.
Returns
OK if the callback is successfully installed.

◆ OS_WaitUntilDataReady()

uint32_t OS_WaitUntilDataReady ( )

Yeilds CPU to other tasks until NCN26010 signals that data is available.

Returns
OK if returning after the data ready interrupt, OS_UNKNOWN_ERROR otherwise.


NCN26010 Example Software: T1S_RSL10Hardware.c File Reference

Macros | Functions | Variables
T1S_RSL10Hardware.c File Reference

This application file includes DMA SPI communication related API calls required to communicate with NCN26010. More...

#include "app.h"
#include <T1S_Hardware.h>

Macros

#define | DIO_INTERRUPT_CH(void) 0
Interrupt Service Routine for IRQn pin interrupt. This interrupt occurs when IRQn pin goes low i.e. when data is available to be read by T1S. More...
#define | SPI_CLK_DIO 12
#define | SPI_CS_DIO 9
#define | SPI_MOSI_DIO 10
#define | SPI_MISO_DIO 11
#define | SPI_INT_DIO 6
#define | SPI_SPEED SPI0_PRESCALE_2
#define | DMA_SPI_TX_CH(void) 0
Interrupt Service Routine for DMA SPI TX interrupts. This interrupt occurs when DMA transfer is done. More...
#define | DMA_SPI_TX_CFG
#define | DMA_SPI_RX_CH 1
#define | DMA_SPI_RX_CFG
#define | THREE_BLOCK_APPN(x, y, z) x##y##z
#define | DMA_IRQn(x) THREE_BLOCK_APPN(DMA, x, _IRQn)
#define | DMA_IRQ_FUNC(x) THREE_BLOCK_APPN(DMA, x, _IRQHandler)
#define | DIO_IRQn(x) THREE_BLOCK_APPN(DIO, x, _IRQn)
#define | DIO_IRQ_FUNC(x) THREE_BLOCK_APPN(DIO, x, _IRQHandler)
#define | CONCAT(x, y) x##y
#define | DIO_SRC(x) CONCAT(DIO_SRC_DIO_, x)

Functions

uint32_t | SPI_Init (void)
Initialization Callback for SPI Code. Must be called before the first SPI_Transfer. More...
uint32_t | SPI_Transfer (uint8_t *rx_buffer, uint8_t *tx_buffer, uint16_t num_bytes_to_transfer)
Transmits and Recieves Data with NCN26010 over a bidirectional SPI interface. More...
uint32_t | SPI_SetErrorCallback (ErrorCallback_t callback)
uint32_t | SetDataReadyISR (ISR_t callback)
Configures hardware to call callback when the NCN26010 asserts its interrupt. More...
uint32_t | SPI_Cleanup ()
Frees SPI module and deinitializes. More...
void | DelayMicroseconds (uint32_t delay_us)
Uses hardware timers to delay the requested number of microseconds. More...
uint32_t | SleepUntilISR ()
Put MCU in a low power mode that will wait until an interrupt. More...

Variables

volatile uint8_t spi_busy

Detailed Description

This application file includes DMA SPI communication related API calls required to communicate with NCN26010.

$Rev: $ $Date:$

Copyright
(c) 2022 ON Semiconductor. All rights reserved. ON Semiconductor is supplying this software for use with ON Semiconductor ethernet products only.

THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

Macro Definition Documentation

◆ DIO_INTERRUPT_CH

#define DIO_INTERRUPT_CH ( void ) 0

Interrupt Service Routine for IRQn pin interrupt. This interrupt occurs when IRQn pin goes low i.e. when data is available to be read by T1S.

Parameters
Interrupt pin number
Returns
None.

◆ DMA_SPI_RX_CFG

#define DMA_SPI_RX_CFG
Value:
(DMA_ENABLE | \
DMA_ADDR_CIRC | \
DMA_TRANSFER_P_TO_M | \
DMA_PRIORITY_0 | \
DMA_DISABLE_INT_DISABLE | \
DMA_ERROR_INT_DISABLE | \
DMA_COMPLETE_INT_DISABLE | \
DMA_COUNTER_INT_DISABLE | \
DMA_START_INT_DISABLE | \
DMA_LITTLE_ENDIAN | \
DMA_SRC_ADDR_STATIC | \
DMA_SRC_WORD_SIZE_8 | \
DMA_SRC_SPI0 | \
DMA_DEST_ADDR_STEP_SIZE_1 | \
DMA_DEST_ADDR_INC | \
DMA_DEST_WORD_SIZE_32)

◆ DMA_SPI_TX_CFG

#define DMA_SPI_TX_CFG
Value:
(DMA_ENABLE | \
DMA_ADDR_LIN | \
DMA_TRANSFER_M_TO_P | \
DMA_PRIORITY_0 | \
DMA_DISABLE_INT_DISABLE | \
DMA_ERROR_INT_DISABLE | \
DMA_COMPLETE_INT_ENABLE | \
DMA_COUNTER_INT_DISABLE | \
DMA_START_INT_DISABLE | \
DMA_LITTLE_ENDIAN | \
DMA_SRC_ADDR_INC | \
DMA_SRC_WORD_SIZE_32 | \
DMA_SRC_ADDR_STEP_SIZE_1 | \
DMA_DEST_ADDR_STATIC | \
DMA_DEST_SPI0 | \
DMA_DEST_WORD_SIZE_8)

◆ DMA_SPI_TX_CH

#define DMA_SPI_TX_CH ( void ) 0

Interrupt Service Routine for DMA SPI TX interrupts. This interrupt occurs when DMA transfer is done.

Parameters
DMA TX channel number
Returns
None.

Function Documentation

◆ DelayMicroseconds()

void DelayMicroseconds ( uint32_t microseconds )

Uses hardware timers to delay the requested number of microseconds.

Parameters
microseconds The number of microseconds to delay
Returns
OK if returning after the requested number of microseconds.

◆ SetDataReadyISR()

uint32_t SetDataReadyISR ( ISR_t callback )

Configures hardware to call callback when the NCN26010 asserts its interrupt.

Parameters
callback A function pointer to ISR_t to call when the interrupt fires.
Returns
OK if the interrupt service routine is successfully installed.

◆ SleepUntilISR()

uint32_t SleepUntilISR ( )

Put MCU in a low power mode that will wait until an interrupt.

Returns
OK after the next interrupt if successful.

◆ SPI_Cleanup()

uint32_t SPI_Cleanup ( )

Frees SPI module and deinitializes.

Returns
OK if successfully cleaned up.

◆ SPI_Init()

uint32_t SPI_Init ( )

Initialization Callback for SPI Code. Must be called before the first SPI_Transfer.

Returns
OK if successfully initalized, SPI_INIT_ERROR otherwise.

◆ SPI_Transfer()

uint32_t SPI_Transfer | ( | uint8_t * | rx_buffer,
 |  | uint8_t * | tx_buffer,
 |  | uint16_t | num_bytes_to_transfer
 | ) |  |

Transmits and Recieves Data with NCN26010 over a bidirectional SPI interface.

Parameters
rx_buffer | A pointer to where received data should be placed.
tx_buffer | A pointer to where data to be trasfered is stored.
num_bytes_to_transfer | The number of bytes to send and receive over SPI
Returns
OK if all data successfuly transfered. SPI_ERROR otherwise.


NCN26010 Example Software: T1S_TCP-IP.h File Reference

Macros | Functions
T1S_TCP-IP.h File Reference

Defines function prototypes for interfacing with the TCP/IP layers of the network stack. More...

#include <stdint.h>
#include "ncn26010.h"

Go to the source code of this file.

Macros

#define | OK (uint32_t) 0
#define | PEND (uint32_t) 1
#define | TCPIP_UNKNOWN_ERROR (uint32_t) 2

Functions

uint32_t | TCPIP_Init ()
Initialization Callback for TCP/IP Code. More...
uint32_t | TCPIP_Receive (uint8_t *buffer, uint16_t number_of_bytes_received)
Transfers data in a buffer into the TCP/IP Stack. More...
uint32_t | TCPIP_PollCallback (uint8_t transmitCreditsAvailable_TXC)
Callback called frequently to allow for the TCPIP code to poll the TCP/IP stack to see if data is available. More...
uint32_t | setMACAddress (uint32_t address)
Configures the NCN26010 to accept the given MAC address. Must be called before TCPIP_Init. More...
uint32_t | setIPAddress (uint32_t address)
Configures the TCP/IP stack to claim the given IP address. Must be called before TCPIP_Init. More...

Detailed Description

Defines function prototypes for interfacing with the TCP/IP layers of the network stack.

Author
Arndt Schuebel, Kyle Storey. $Rev: $
Date
Copyright
(c) 2022 ON Semiconductor. All rights reserved. ON Semiconductor is supplying this software for use with ON Semiconductor ethernet products only.

THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

Function Documentation

◆ setIPAddress()

uint32_t setIPAddress ( uint32_t address )

Configures the TCP/IP stack to claim the given IP address. Must be called before TCPIP_Init.

Parameters
address The IP address
Returns
OK if no erros occurred, TCPIP_UNKNOWN_ERROR otherwise.

◆ setMACAddress()

uint32_t setMACAddress ( uint32_t address )

Configures the NCN26010 to accept the given MAC address. Must be called before TCPIP_Init.

Parameters
address The MAC address
Returns
OK if no erros occurred, TCPIP_UNKNOWN_ERROR otherwise.

◆ TCPIP_Init()

uint32_t TCPIP_Init ( )

Initialization Callback for TCP/IP Code.

Returns
OK if successfully initalized, TCPIP_UNKNOWN_ERROR otherwise.

◆ TCPIP_PollCallback()

uint32_t TCPIP_PollCallback ( uint8_t transmitCreditsAvailable_TXC )

Callback called frequently to allow for the TCPIP code to poll the TCP/IP stack to see if data is available.

Parameters
transmitCreditsAvailable_TXC The number of available chunks that will fit in NCN26010 buffer.
Returns
OK if no erros occurred, TCPIP_UNKNOWN_ERROR otherwise.

◆ TCPIP_Receive()

uint32_t TCPIP_Receive | ( | uint8_t * | buffer,
 |  | uint16_t | number_of_bytes_received
 | ) |  |

Transfers data in a buffer into the TCP/IP Stack.

Parameters
buffer | A pointer to where the data to be received is stored
number_of_bytes_received | The number of bytes in the buffer to transfer to the TCP/IP stack
Returns
OK if successfully transfered into the TCP/IP stack, TCPIP_UNKNOWN_ERROR otherwise.


NCN26010 Example Software: Globals

  • All
  • Functions
  • Macros
  • c
  • d
  • g
  • i
  • m
  • n
  • o
  • s
  • t
Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation:

- c -

  • ConvertEndianness() : NCN26010.c

- d -

  • DelayMicroseconds() : T1S_Hardware.h, T1S_RSL10Hardware.c
  • DIO_INTERRUPT_CH : T1S_RSL10Hardware.c
  • DMA_SPI_TX_CH : T1S_RSL10Hardware.c

- g -

  • GetTick() : T1S_Hardware.h

- i -

  • Initialize() : app.c, app.h

- m -

  • main() : app.c

- n -

  • NCN26010_Exit() : NCN26010.c, NCN26010.h
  • NCN26010_Init() : NCN26010.c, NCN26010.h
  • NCN26010_Loop() : NCN26010.c, NCN26010.h

- o -

  • OS_Init() : T1S_FreeRTOS_OS.c, T1S_OS.h
  • OS_SetDataReadyCallback() : T1S_FreeRTOS_OS.c, T1S_OS.h
  • OS_Start() : T1S_FreeRTOS_OS.c, T1S_OS.h
  • OS_WaitUntilDataReady() : T1S_OS.h

- s -

  • SetDataReadyISR() : T1S_Hardware.h, T1S_RSL10Hardware.c
  • setIPAddress() : T1S_TCP-IP.h
  • setMACAddress() : T1S_TCP-IP.h
  • SleepUntilISR() : T1S_Hardware.h, T1S_RSL10Hardware.c
  • SPI_Cleanup() : T1S_Hardware.h, T1S_RSL10Hardware.c
  • SPI_Init() : T1S_Hardware.h, T1S_RSL10Hardware.c
  • SPI_Transfer() : T1S_Hardware.h, T1S_RSL10Hardware.c

- t -

  • T1S_ClearStatus() : NCN26010.c, NCN26010.h
  • T1S_ConfigurePLCA() : NCN26010.c, NCN26010.h
  • T1S_Receive() : NCN26010.c
  • T1S_RegRead() : NCN26010.c, NCN26010.h
  • T1S_RegWrite() : NCN26010.c, NCN26010.h
  • T1S_SendRemoteConfiguration() : NCN26010.h
  • T1S_Transmit() : NCN26010.c, NCN26010.h
  • TCPIP_Init() : T1S_FreeRTOS_TCP-IP.c, T1S_LWIPTCP-IP.c, T1S_TCP-IP.h
  • TCPIP_PollCallback() : T1S_FreeRTOS_TCP-IP.c, T1S_LWIPTCP-IP.c, T1S_TCP-IP.h
  • TCPIP_Receive() : T1S_FreeRTOS_TCP-IP.c, T1S_LWIPTCP-IP.c, T1S_TCP-IP.h


NCN26010 Example Software: Globals

  • All
  • Functions
  • Macros
  • c
  • d
  • g
  • i
  • m
  • n
  • o
  • s
  • t

- c -

  • ConvertEndianness() : NCN26010.c

- d -

  • DelayMicroseconds() : T1S_Hardware.h, T1S_RSL10Hardware.c

- g -

  • GetTick() : T1S_Hardware.h

- i -

  • Initialize() : app.c, app.h

- m -

  • main() : app.c

- n -

  • NCN26010_Exit() : NCN26010.c, NCN26010.h
  • NCN26010_Init() : NCN26010.c, NCN26010.h
  • NCN26010_Loop() : NCN26010.c, NCN26010.h

- o -

  • OS_Init() : T1S_FreeRTOS_OS.c, T1S_OS.h
  • OS_SetDataReadyCallback() : T1S_FreeRTOS_OS.c, T1S_OS.h
  • OS_Start() : T1S_FreeRTOS_OS.c, T1S_OS.h
  • OS_WaitUntilDataReady() : T1S_OS.h

- s -

  • SetDataReadyISR() : T1S_Hardware.h, T1S_RSL10Hardware.c
  • setIPAddress() : T1S_TCP-IP.h
  • setMACAddress() : T1S_TCP-IP.h
  • SleepUntilISR() : T1S_Hardware.h, T1S_RSL10Hardware.c
  • SPI_Cleanup() : T1S_Hardware.h, T1S_RSL10Hardware.c
  • SPI_Init() : T1S_Hardware.h, T1S_RSL10Hardware.c
  • SPI_Transfer() : T1S_Hardware.h, T1S_RSL10Hardware.c

- t -

  • T1S_ClearStatus() : NCN26010.c, NCN26010.h
  • T1S_ConfigurePLCA() : NCN26010.c, NCN26010.h
  • T1S_Receive() : NCN26010.c
  • T1S_RegRead() : NCN26010.c, NCN26010.h
  • T1S_RegWrite() : NCN26010.c, NCN26010.h
  • T1S_SendRemoteConfiguration() : NCN26010.h
  • T1S_Transmit() : NCN26010.c, NCN26010.h
  • TCPIP_Init() : T1S_FreeRTOS_TCP-IP.c, T1S_LWIPTCP-IP.c, T1S_TCP-IP.h
  • TCPIP_PollCallback() : T1S_FreeRTOS_TCP-IP.c, T1S_LWIPTCP-IP.c, T1S_TCP-IP.h
  • TCPIP_Receive() : T1S_FreeRTOS_TCP-IP.c, T1S_LWIPTCP-IP.c, T1S_TCP-IP.h


NCN26010 Example Software: Globals

  • All
  • Functions
  • Macros
  • DIO_INTERRUPT_CH : T1S_RSL10Hardware.c
  • DMA_SPI_TX_CH : T1S_RSL10Hardware.c


NCN26010 Example Software: NCN26010.h Source File

NCN26010.h
Go to the documentation of this file.
1#ifndef NCN26010_H
2#define NCN26010_H
3/***************************************************************************/
25#include <stdbool.h>
26#include <stdint.h>
27
28/*************************************************************************************************
29* Configuration
30*************************************************************************************************/
31#define REMOTE_CONFIGURATION_ENABLED 1
32#define PLCA_ENABLED (bool) false
33#define PLCA_ROLE (bool) false //Not a leader unless ID 0
34#define PLCA_ID_INIT (uint8_t) 0 //LEADER
35#define PLCA_NODE_COUNT (uint8_t) 4 //4 nodes
36#define ENI_ENABLED (bool) false //Enhanced Noise Immunity
37#define POLLING 0
38#define USE_INTERNAL_MAC_ADDRESS 1 //If true read the MAC stored in the NCN26010 otherwise use DEFAULT_MAC_ADDRESS
39#define MAC_PROMISCUOUS_MODE 0
40#define DEFAULT_MAC_ADDRESS {0x60, 0xC0, 0xBF, 0x01, 0x01, 0x01}
41#define DEFAULT_IP_ADDRESS_ARRAY {192, 1, 1, 1}
42#define DEFAULT_IP_ADDRESS 0x010101c0 //matches 192.1.1.1
43
44/*************************************************************************************************
45* Symbolic constants *
46*************************************************************************************************/
47
48#define MAX_PAYLOAD_BYTE (uint8_t) 64 // ToDo This is configurable so need to change based on configuration
49#define EACH_REG_SIZE (uint8_t) 4
50#define MAX_REG_DATA_ONECHUNK (uint8_t) (MAX_PAYLOAD_BYTE/EACH_REG_SIZE)
51#define MAX_DATA_DWORD_ONECHUNK MAX_REG_DATA_ONECHUNK
52#define HEADER_FOOTER_SIZE (uint8_t)4
53#define STATUS_OK(status) (uint8_t)(((status) & 0xFFFFFFF7) == 0x00000000)
54#define SIZE_OF_MAC_ADDR (uint8_t)6
55#define ENABLE_MAC_FILTER (uint32_t)1 << 31
56
57/*************************************************************************************************
58* Global Configuration *
59*************************************************************************************************/
60
61extern uint8_t g_currentNodeMACAddr[SIZE_OF_MAC_ADDR];
62
63/**************************************************************************************************
64 * Structures
65 *************************************************************************************************/
66
67typedef struct
68{
69 uint8_t type;
70 uint8_t MMS;
71 uint16_t address;
72 uint32_t data;
73} stRemoteConfigurationCommand_t;
74
75/*************************************************************************************************
76 * Error Codes
77 ************************************************************************************************/
78
79#define OK (uint32_t) 0
80#define UNKNOWN_ERROR (uint32_t) 1
81#define PHYSICAL_COLLISSION_ERROR 2
82#define PLCA_RECOVERY_ERROR 3
83#define REMOTE_JABBER_ERROR 4
84#define LOCAL_JABBER_ERROR 5
85#define RX_BUFFER_OVERFLOW_ERROR 6
86#define TX_BUFFER_OVERFLOW_ERROR 7
87#define TX_BUFFER_UNDERFLOW_ERROR 8
88#define REGISTER_READ_ERROR 9
89#define INIT_ERROR 10
90#define SIZE_OF_MAC_ADDR (uint8_t)6
91//TODO FILL IN ALL POSSIBLE ERRORS
92
93/*************************************************************************************************
94 * Prototypes
95 ************************************************************************************************/
103uint32_t T1S_ConfigurePLCA(uint8_t id, uint8_t max_id, bool enabled);
108uint32_t NCN26010_Init(); // Configures as defined in this header. Returns 0 on success otherwise an error code
113uint32_t NCN26010_Loop();
120uint32_t T1S_Transmit(uint8_t* txBuffer, uint16_t num_bytes_to_transmit); //create a ethernet frame and transfer the given data. Return 0 on success otherwise an error code connected with the problem
127uint32_t T1S_RegRead(uint8_t MMS, uint16_t address); //return the value in the given address
134uint32_t T1S_RegWrite(uint8_t MMS, uint16_t address, uint32_t data); //write the given value in the given address
141uint32_t T1S_SendRemoteConfiguration(uint8_t targetMAC[SIZE_OF_MAC_ADDR], stRemoteConfigurationCommand_t* commands, uint32_t numCommands);
146uint32_t T1S_ClearStatus();
151uint32_t NCN26010_Exit();
152
153#endif /* NCN26010_H */
NCN26010_Exit
uint32_t NCN26010_Exit()
Sets a flag to cause NCN26010_Loop to exit after the next iteration.
Definition: NCN26010.c:1309
T1S_SendRemoteConfiguration
uint32_t T1S_SendRemoteConfiguration(uint8_t targetMAC[SIZE_OF_MAC_ADDR], stRemoteConfigurationCommand_t *commands, uint32_t numCommands)
Reads or writes registers of a remote NCN26010. May be disbled by defining REMOTE_CONFIGURATION_ENABL...
T1S_RegRead
uint32_t T1S_RegRead(uint8_t MMS, uint16_t address)
Reads a register on the NCN26010 over SPI.
Definition: NCN26010.c:724
NCN26010_Loop
uint32_t NCN26010_Loop()
Endless loop to retrieve data from NCN26010 to the TCP/IP stack and vice versa. Calls OS_WaitUntilISR...
Definition: NCN26010.c:1283
T1S_Transmit
uint32_t T1S_Transmit(uint8_t *txBuffer, uint16_t num_bytes_to_transmit)
Assenbles txBuffer into chunks and transfers then to the NCN26010 to be trasmitted over T1S.
Definition: NCN26010.c:780
NCN26010_Init
uint32_t NCN26010_Init()
Definition: NCN26010.c:288
T1S_RegWrite
uint32_t T1S_RegWrite(uint8_t MMS, uint16_t address, uint32_t data)
Writes a register on the NCN26010 over SPI.
Definition: NCN26010.c:745
T1S_ClearStatus
uint32_t T1S_ClearStatus()
Reads and clears the NCN26010 status register (MMS 0, 0x8).
Definition: NCN26010.c:765
T1S_ConfigurePLCA
uint32_t T1S_ConfigurePLCA(uint8_t id, uint8_t max_id, bool enabled)
Saves configuration options for Physical Layer Colision Avoidance. Must be called before NCN26010_Ini...
Definition: NCN26010.c:1316
stRemoteConfigurationCommand_t
Definition: NCN26010.h:68


NCN26010 Example Software: Network_transport_layer.h Source File

Network_transport_layer.h
Go to the documentation of this file.
1/* USER CODE BEGIN Header */
12/* USER CODE END Header */
13
14/* Define to prevent recursive inclusion -------------------------------------*/
15#ifndef __NETWORK_TRANSPORT_LAYER_H
16#define __NETWORK_TRANSPORT_LAYER_H
17
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/* Includes ------------------------------------------------------------------*/
24#include "lwip/tcpip.h"
25#include "lwip/ip_addr.h"
26#include "lwip/err.h"
27#include "lwip/pbuf.h"
28#include "lwip/tcpbase.h"
29#include "lwip/debug.h"
30#include "lwip/stats.h"
31#include "lwip/tcp.h"
32#include "lwip/apps/lwiperf.h"
33
34#define USE_DHCP 0 /* enable DHCP, if disabled static address is used */
35
36/*Static IP ADDRESS: IP_ADDR0.IP_ADDR1.IP_ADDR2.IP_ADDR3 */
37/*#define IP_ADDR0 (uint8_t) 192
38#define IP_ADDR1 (uint8_t) 1
39#define IP_ADDR2 (uint8_t) 1
40#define IP_ADDR3 (uint8_t) 4
41
42#define IP_ADDR5 (uint8_t) 3*/
43
44
45
46
47#endif


NCN26010 Example Software: T1S_Hardware.h Source File

T1S_Hardware.h
Go to the documentation of this file.
1#ifndef T1S_HARDWARE_H
2#define T1S_HARDWARE_H
3/***************************************************************************/
25#include <stdint.h>
26typedef void (*ISR_t)(uint32_t tick);
27typedef void (*ErrorCallback_t)(uint32_t error);
28
29/*************************************************************************************************
30 * Error Codes
31 ************************************************************************************************/
32#define OK (uint32_t) 0
33#define SPI_ERROR (uint32_t) 1
34#define SPI_INIT_ERROR (uint32_t) 2
35#define ISR_INIT_ERROR (uint32_t) 3
36//TODO fill in other error codes
37
38/*************************************************************************************************
39 * Prototypes
40 ************************************************************************************************/
45uint32_t SPI_Init(); //Configures to send and recieve SPI data to the NCN26010. Return true on success
53uint32_t SPI_Transfer(uint8_t* rx_buffer, uint8_t* tx_buffer, uint16_t num_bytes_to_transfer); //transfer data over spi. Return true on success
59uint32_t SetDataReadyISR(ISR_t callback); //register a callback for when we get a data ready interrupt
65void DelayMicroseconds(uint32_t microseconds); //returns after the number of microseconds specified
70uint32_t GetTick(); //returns current time in milliseconds
75uint32_t SPI_Cleanup();
80uint32_t SleepUntilISR();
81
82
83#endif /*T1S_HARDWARE_H*/
SleepUntilISR
uint32_t SleepUntilISR()
Put MCU in a low power mode that will wait until an interrupt.
Definition: T1S_RSL10Hardware.c:240
SPI_Cleanup
uint32_t SPI_Cleanup()
Frees SPI module and deinitializes.
Definition: T1S_RSL10Hardware.c:232
SPI_Init
uint32_t SPI_Init()
Initialization Callback for SPI Code. Must be called before the first SPI_Transfer.
Definition: T1S_RSL10Hardware.c:132
DelayMicroseconds
void DelayMicroseconds(uint32_t microseconds)
Uses hardware timers to delay the requested number of microseconds.
Definition: T1S_RSL10Hardware.c:236
SPI_Transfer
uint32_t SPI_Transfer(uint8_t *rx_buffer, uint8_t *tx_buffer, uint16_t num_bytes_to_transfer)
Transmits and Recieves Data with NCN26010 over a bidirectional SPI interface.
Definition: T1S_RSL10Hardware.c:164
GetTick
uint32_t GetTick()
Reads hardware timers to get the current time in milliseconds.
Definition: T1S_STM32_Hardware.c:242
SetDataReadyISR
uint32_t SetDataReadyISR(ISR_t callback)
Configures hardware to call callback when the NCN26010 asserts its interrupt.
Definition: T1S_RSL10Hardware.c:226


NCN26010 Example Software: T1S_OS.h Source File

T1S_OS.h
Go to the documentation of this file.
1#ifndef T1S_OS_H
2#define T1S_OS_H
3/***************************************************************************/
25#include <stdint.h>
26#include <T1S_Hardware.h>
27typedef void (*ISR_t)(uint32_t tick);
28
29/*************************************************************************************************
30 * Error Codes
31 ************************************************************************************************/
32#define OK (uint32_t) 0
33#define OS_UNKNOWN_ERROR (uint32_t) 1
34
35/*************************************************************************************************
36 * Prototypes
37 ************************************************************************************************/
42uint32_t OS_Init();
46void OS_Start();
51uint32_t OS_WaitUntilDataReady();
58uint32_t OS_SetDataReadyCallback(ISR_t callback);
59
60
61#endif /*T1S_OS_H*/
T1S_Hardware.h
Defines function prototypes for hardware specific functions required by NCN26010.
OS_WaitUntilDataReady
uint32_t OS_WaitUntilDataReady()
Yeilds CPU to other tasks until NCN26010 signals that data is available.
OS_Init
uint32_t OS_Init()
Initialization Callback for OS Code. Called after SPI_Init.
Definition: T1S_FreeRTOS_OS.c:57
OS_SetDataReadyCallback
uint32_t OS_SetDataReadyCallback(ISR_t callback)
Coordinates with hardware to call callback when the NCN26010 signals that data is available....
Definition: T1S_FreeRTOS_OS.c:125
OS_Start
void OS_Start()
Starts the OS scheduler. Never returns.
Definition: T1S_FreeRTOS_OS.c:92


NCN26010 Example Software: T1S_TCP-IP.h Source File

T1S_TCP-IP.h
Go to the documentation of this file.
1#ifndef T1S_TCPIP_H
2#define T1S_TCPIP_H
3/***************************************************************************/
25#include <stdint.h>
26#include "ncn26010.h"
27
28/*************************************************************************************************
29 * Error Codes
30 ************************************************************************************************/
31#define OK (uint32_t) 0
32#define PEND (uint32_t) 1
33#define TCPIP_UNKNOWN_ERROR (uint32_t) 2
34//TODO fill in other error codes
35
36/*************************************************************************************************
37 * Prototypes
38 ************************************************************************************************/
43uint32_t TCPIP_Init();
50uint32_t TCPIP_Receive(uint8_t* buffer, uint16_t number_of_bytes_received);
56uint32_t TCPIP_PollCallback(uint8_t transmitCreditsAvailable_TXC);
62uint32_t setMACAddress(uint32_t address); //calls RegWrite in NCN26010
68uint32_t setIPAddress(uint32_t address); //
69
70#endif /* T1S_TCPIP_H */
NCN26010.h
Support functions to simplify utilization of NCN26010 Features.
TCPIP_Receive
uint32_t TCPIP_Receive(uint8_t *buffer, uint16_t number_of_bytes_received)
Transfers data in a buffer into the TCP/IP Stack.
Definition: T1S_FreeRTOS_TCP-IP.c:45
TCPIP_PollCallback
uint32_t TCPIP_PollCallback(uint8_t transmitCreditsAvailable_TXC)
Callback called frequently to allow for the TCPIP code to poll the TCP/IP stack to see if data is ava...
Definition: T1S_FreeRTOS_TCP-IP.c:85
setIPAddress
uint32_t setIPAddress(uint32_t address)
Configures the TCP/IP stack to claim the given IP address. Must be called before TCPIP_Init.
TCPIP_Init
uint32_t TCPIP_Init()
Initialization Callback for TCP/IP Code.
Definition: T1S_FreeRTOS_TCP-IP.c:41
setMACAddress
uint32_t setMACAddress(uint32_t address)
Configures the NCN26010 to accept the given MAC address. Must be called before TCPIP_Init.


NCN26010 Example Software: app.h Source File

app.h
Go to the documentation of this file.
1/***************************************************************************/
23#ifndef APP_H
24#define APP_H
25
26/* ----------------------------------------------------------------------------
27 * If building with a C++ compiler, make all of the definitions in this header
28 * have a C binding.
29 * ------------------------------------------------------------------------- */
30#ifdef __cplusplus
31extern "C"
32{
33#endif /* ifdef __cplusplus */
34
35/*************************************************************************************************
36* Include Files
37*************************************************************************************************/
38#include <RTE_Components.h>
39#include CMSIS_device_header
40#include <cmsis_os2.h>
41#include <printf.h>
42
43/*************************************************************************************************
44* Global Variables
45*************************************************************************************************/
46/* DIO number that is used for easy re-flashing (recovery mode) */
47#define RECOVERY_DIO 12
48
49/*************************************************************************************************
50 * Prototypes
51 ************************************************************************************************/
57void Initialize(void);
58
59/* ----------------------------------------------------------------------------
60 * Close the 'extern "C"' block
61 * ------------------------------------------------------------------------- */
62#ifdef __cplusplus
63}
64#endif /* ifdef __cplusplus */
65
66#endif /* APP_H */
Initialize
void Initialize(void)
Initialize the system by disabling interrupts, configuring the required clock settings,...
Definition: app.c:38